/**
 * 获取url中的参数
 * @param {Object} paraName
 */
function getUrlParam(paraName) {
	var url = window.location.toString();
	var arrObj = url.split("?");

	if (arrObj.length > 1) {
		var arrPara = arrObj[1].split("&");
		var arr;

		for (var i = 0; i < arrPara.length; i++) {
			arr = arrPara[i].split("=");

			if (arr != null && arr[0] == paraName) {
				return arr[1];
			}
		}
		return "";
	} else {
		return "";
	}
}
/**
 * 数组转为逗号拼接的字符串
 * @param {Object} arry
 */
function getStrByArry(arr) {

	var str = "";
	for (var i = 0; i < arr.length; i++) {
		str += arr[i] + ",";
	}
	//去掉最后一个逗号(如果不需要去掉，就不用写)
	if (str.length > 0) {
		str = str.substr(0, str.length - 1);
	}
	return str;
}
/**
 * 字符串转为数组
 * @param {Object} str
 */
function getArryByStr(str) {
	var arr = str.split(",");
	return arr;
}

/**iframe 打开新的tab
 * @param {Object} uri 求情地址
 * @param {Object} title 标题
 * @param {Object} icon 图标
 */
function openTabs(uri, title, icon) {

	// "title": "demo",
	// "icon": "el-icon-goods",
	// "href": "pages/demo/index.html",
	// "id": "4"
	let parameters = {};
	parameters.name = title;
	parameters.url = uri;
	parameters.icon = icon;
	var id = md5(parameters.name + parameters.url + parameters.icon);
	console.log(id);
	parameters.id = id;
	console.log(parameters);
	parent.vm.openTabs(parameters);
}
Array.prototype.remove = function(from, to) {
	var rest = this.slice((to || from) + 1 || this.length);
	this.length = from < 0 ? this.length + from : from;
	return this.push.apply(this, rest);
};
/**
 * 获取url中的参数
 * @param {Object} paraName
 */
function getUrlParam(paraName) {
	var url = window.location.toString();
	var arrObj = url.split("?");
	if (arrObj.length > 1) {
		var arrPara = arrObj[1].split("&");
		var arr;
		for (var i = 0; i < arrPara.length; i++) {
			arr = arrPara[i].split("=");
			if (arr != null && arr[0] == paraName) {
				return arr[1];
			}
		}
		return "";
	} else {
		return "";
	}
}
/**
 * 数组转为逗号拼接的字符串
 * @param {Object} arry
 */
function getStrByArry(arr) {
	var str = "";
	for (var i = 0; i < arr.length; i++) {
		str += arr[i] + ",";
	}
	//去掉最后一个逗号(如果不需要去掉，就不用写)
	if (str.length > 0) {
		str = str.substr(0, str.length - 1);
	}
	return str;
}
/**
 * 字符串转为数组
 * @param {Object} str
 */
function getArryByStr(str) {
	var arr = str.split(",");
	return arr;
}
/**
 * 树形数据转换
 * @param {*} data
 * @param {*} id
 * @param {*} pid
 */
function treeDataTranslate(data, id = 'id', pid = 'parentId') {
	var res = []
	var temp = {}
	for (var i = 0; i < data.length; i++) {
		temp[data[i][id]] = data[i]
	}
	for (var k = 0; k < data.length; k++) {
		if (temp[data[k][pid]] && data[k][id] !== data[k][pid]) {
			if (!temp[data[k][pid]]['children']) {
				temp[data[k][pid]]['children'] = []
			}
			if (!temp[data[k][pid]]['_level']) {
				temp[data[k][pid]]['_level'] = 1
			}
			data[k]['_level'] = temp[data[k][pid]]._level + 1
			temp[data[k][pid]]['children'].push(data[k])
		} else {
			res.push(data[k])
		}
	}
	return res
}
/**
 * 邮箱
 * @param {*} s
 */
function isEmail(s) {
	return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s)
}
/**
 * 手机号码
 * @param {*} s
 */
function isMobile(s) {
	return /^1[0-9]{10}$/.test(s)
}
/**
 * 电话号码
 * @param {*} s
 */
function isPhone(s) {
	return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s)
}
/**
 * URL地址
 * @param {*} s
 */
function isURL(s) {
	return /^http[s]?:\/\/.*/.test(s)
}


//网关地址

